using System.Collections.Generic;
using UnityEngine;

public class Chall_infoUI : MonoBehaviour
{
	public UIEventListener closebtn;

	//public Animation scaleanima;
	public Animator animator;

	public UILabel name_label;

	public UILabel info_label;

	public Piece_item[] pieceitem;

	public GameObject[] pieceobj;

	private GameObject objui;

	private List<PieceData> getpiecelist = new List<PieceData>();

	private string[] infocontent = new string[4]
	{
		"1.敌人共有 20 波。\n2.尽量坚持下去。\n3.你可以获得钻石、\n丰富的经验，甚至是部件。",
		"1.这是团队竞赛模式。\n2.与队友一起战斗。\n3.你可以获得钻石、\n丰富的经验，甚至是部件。",
		"1.你的目标是敌方建筑。\n2.摧毁敌方建筑并保护我方建筑。\n3.你有 5 分钟。\n4.你可以获得钻石、\n丰富的经验，甚至是部件。",
		"1.所有飞机都是敌人！\n2.你有 5 分钟进行战斗。\n3.你可以获得钻石、\n丰富的经验，甚至是部件。"
	};

	private bool isshow;

	private void Start()
	{
		closebtn.onClick = OnClickcloseBtn;
	}

	public void enable(int challindex)
	{
		if (objui == null)
		{
			objui = base.gameObject;
		}
		UnityVersionUtil.SetActiveRecursive(objui, state: true);
		/* scaleanima["PopWinAnimation"].time = 0f;
		scaleanima["PopWinAnimation"].speed = 1f;
		scaleanima.Play(); */
		animator.SetTrigger("popWin1");
		switch (challindex)
		{
			case 6:
				name_label.text = "生存";
				break;
			case 7:
				name_label.text = "团队死亡竞赛";
				break;
			case 8:
				name_label.text = "保卫基地";
				break;
			case 9:
				name_label.text = "自由对抗";
				break;
		}
		info_label.text = infocontent[challindex - 6];
		getpiecelist = MenuDataController.instance.GetChallgePiece(challindex);
		for (int i = 0; i < 3; i++)
		{
			if (i < getpiecelist.Count)
			{
				pieceitem[i].enable(getpiecelist[i]);
				NGUITools.SetActive(pieceobj[i], state: true);
			}
			else
			{
				NGUITools.SetActive(pieceobj[i], state: false);
			}
		}
		isshow = true;
	}

	public void OnClickcloseBtn(GameObject btn)
	{
		if (isshow)
		{
			isshow = false;
			MonoInstance<AudioController>.instance.play(AudioType.UI_BTN, 0f);
			/* scaleanima["PopWinAnimation"].time = scaleanima.clip.length;
			scaleanima["PopWinAnimation"].speed = -1f;
			scaleanima.Play(); */
			animator.SetTrigger("popWin2");
			Invoke("disable", animator.runtimeAnimatorController.animationClips[0].length);
		}
	}

	public void disable()
	{
		animator.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
		MenuBackController.instance.BackMenuUIstate();
		UnityVersionUtil.SetActiveRecursive(objui, state: false);
	}
}
